num, op = "123456789", ["", "+", "-"] # empty is also an op
for p in range(len(op)**(len(num)-1)):
    calcstr = num[:1]
    for idx in range(1, len(num)):
        calcstr, p = calcstr + op[p % len(op)] + num[idx], p / len(op)
    print calcstr, "=", eval(calcstr)
 